package com.winit.schedule.core.protocol.command;

import java.util.List;

import com.winit.schedule.core.protocol.AbstractCommandBody;
import com.winit.schedule.core.repository.entity.QuartzSchedulerEntity;
import com.winit.schedule.core.repository.entity.TaskRunnerEntity;
import com.winit.schedule.core.repository.entity.TaskTrackerEntity;

public class HeartbeatRequest extends AbstractCommandBody {

    private TaskTrackerEntity           taskTrackerEntity;

    private List<TaskRunnerEntity>      taskRunners;

    private List<QuartzSchedulerEntity> schedulerEntities;

    public HeartbeatRequest(){

    }

    public HeartbeatRequest(TaskTrackerEntity taskTrackerEntity){
        this(taskTrackerEntity.getTaskTrackerUuid(), taskTrackerEntity.getAvailableThreads());
        this.taskTrackerEntity = taskTrackerEntity;
    }

    public HeartbeatRequest(TaskTrackerEntity taskTrackerEntity, List<TaskRunnerEntity> taskRunners){
        this(taskTrackerEntity.getTaskTrackerUuid(), taskTrackerEntity.getAvailableThreads());
        this.taskTrackerEntity = taskTrackerEntity;
        this.taskRunners = taskRunners;
    }

    public HeartbeatRequest(String identity, Integer availableThreads){
        super(identity, availableThreads);
    }

    public TaskTrackerEntity getTaskTrackerEntity() {
        return taskTrackerEntity;
    }

    public void setTaskTrackerEntity(TaskTrackerEntity taskTrackerEntity) {
        this.taskTrackerEntity = taskTrackerEntity;
    }

    public List<TaskRunnerEntity> getTaskRunners() {
        return taskRunners;
    }

    public void setTaskRunners(List<TaskRunnerEntity> taskRunners) {
        this.taskRunners = taskRunners;
    }

    public List<QuartzSchedulerEntity> getSchedulerEntities() {
        return schedulerEntities;
    }

    public void setSchedulerEntities(List<QuartzSchedulerEntity> schedulerEntities) {
        this.schedulerEntities = schedulerEntities;
    }

    public static enum HeartBeatType {
        NODE_REGISTER, SYNC_STATE;
    }

}
